<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich">



<body>
	<ui:composition template="/template/template.xhtml">
		
		<ui:define name="body">
			<h:form onkeypress="if (event.keyCode == 13) return false;">

				<rich:notifyMessages stayTime="2000" nonblocking="true" />

				<h:panelGrid>
					<rich:panel header="#{msg.search}" rendered="#{floorPlanMaintainBean.status == 'INIT'}">
						<table>
							<tr>
							
								<td>
									<h:outputText value="#{msg.building_name}" styleClass="outputText" style="font-size: 16px;" />
								</td>
								
								<td>
									<h:selectOneMenu id="search_building_name" styleClass="selectClass" value="#{floorPlanMaintainBean.selectedBuildingId}" valueChangeListener="#{floorPlanMaintainBean.buildingValueChanged}">

										<f:selectItems value="#{floorPlanMaintainBean.buildingOptions}" />
										<a4j:ajax event="valueChange" render="search_floor_name" execute="@this" />

									</h:selectOneMenu>
								</td>

								<td>
									<h:outputText value="#{msg.floor_name}" styleClass="outputText" style="font-size: 16px;" />
								</td>
								
								<td>
									<h:selectOneMenu id="search_floor_name" styleClass="selectClass" value="#{floorPlanMaintainBean.selectedFloorId}" >

										<f:selectItems value="#{floorPlanMaintainBean.floorOptions}" />										
									</h:selectOneMenu>
								</td>
																							
								<td>
									<h:outputText value="&#160;" />		
									<h:outputText value="&#160;" />		
									<h:outputText value="&#160;" />	
								</td>
								
								<td>
									<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;" 
										value="#{msg.search}" 
										action="#{floorPlanMaintainBean.search}" 
										render="@form" />								
								</td>
							</tr>
						</table>
					</rich:panel>
					
					<rich:panel header="#{msg.search}" rendered="#{floorPlanMaintainBean.status == 'SEARCH'}">
						<table border="1">
							<caption><h:outputText value="#{floorPlanMaintainBean.selectedFloor.building.buildingName}, #{floorPlanMaintainBean.selectedFloor.floorName}" styleClass="title" /></caption>
							<tr>
								<th width="300px"><h:outputText value="#{msg.room_name}" /></th>
								<th width="300px"><h:outputText value="#{msg.machine_name}" /></th>
								<th width="100px"><h:outputText value="#{msg.x_coordinate}" /></th>
								<th width="100px"><h:outputText value="#{msg.y_coordinate}" /></th>
								<th width="100px"><h:outputText value="#{msg.show}" /></th>
							</tr>
							
							<a4j:repeat value="#{floorPlanMaintainBean.machines}" var="machine" rows="50" id="repeat">
								<tr>
									<td><h:outputText value="#{machine.room.roomName}" /></td>
									<td><h:outputText value="#{machine.machineName}" /></td>	                            
			                        <td>
			                        	<h:inputText value="#{machine.posX}" required="true" 
				                			requiredMessage="#{machine.machineName}-#{msg.required_field}"
				                			converterMessage="#{machine.machineName}-#{msg.invalid_number}"
				                			validatorMessage="#{machine.machineName}-#{msg.invalid_number}: 1~1000"
				                			styleClass="short_inputText" maxlength="4" size="4">
				                			<f:validateLongRange minimum="0" maximum="1000" />
				                		</h:inputText>
			                        </td>
			                        <td>
			                        	<h:inputText value="#{machine.posY}" required="true" 
				                			requiredMessage="#{machine.room.roomName},#{machine.machineName}-#{msg.required_field}"
				                			converterMessage="#{machine.room.roomName},#{machine.machineName}-#{msg.invalid_number}"
				                			validatorMessage="#{machine.room.roomName},#{machine.machineName}-#{msg.invalid_number}: 1~1000"
				                			styleClass="short_inputText" maxlength="4" size="4">
				                			<f:validateLongRange minimum="0" maximum="1000" />
				                		</h:inputText>			                        	                      
			                        </td>
			                        <td>
			                        	<h:selectOneMenu styleClass="short_selectClass" value="#{machine.show}" >	
											<f:selectItem itemLabel="#{msg.trueValue}" itemValue="#{true}" />
											<f:selectItem itemLabel="#{msg.falseValue}" itemValue="#{false}" />																				
										</h:selectOneMenu>				                        
			                        </td>			                        	                        	
	                        	</tr>
							 </a4j:repeat>
							 
							 <tr>
								<td colspan="5" align="right">
									<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;" 
										value="#{msg.save}"
										action="#{floorPlanMaintainBean.save}" 
										render="@form" /> 
										
									<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;"
										value="#{msg.back}" action="#{floorPlanMaintainBean.init}" 										
										render="@form" />
								</td>
							</tr>
						 </table>
					</rich:panel>
									
				</h:panelGrid>

			</h:form>


		</ui:define>
	</ui:composition>
</body>
</html>
